const Sequelize = require('sequelize');
const DB = require("../config/dbconfig");
const userRelationModel = DB.define('user_relation_tab', {
    user_rela_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "用户关系id，主键"
    },
    friend_id: {
      type: Sequelize.INTEGER,
      allowNull: true,
      comment: "与用户表的friend_id一样，是他的外键"
    },
    user_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      references: {
        model: 'user_tab',
        key: 'user_id'
      }
    },
    is_delete:{
      type:Sequelize.INTEGER(2),
      comment:"聊天时间"
    }
  }, {
    Sequelize,
    tableName: 'user_relation_tab',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "user_rela_id" },
        ]
      },
      {
        name: "friend_id",
        using: "BTREE",
        fields: [
          { name: "friend_id" },
        ]
      },
      {
        name: "user_id",
        using: "BTREE",
        fields: [
          { name: "user_id" },
        ]
      },
    ]
  });
module.exports = userRelationModel
